var PurchaseOrderInfo = function (order) {
  BaseModel.call(this);

  var self = this;
  var laterPhaseFields = ['laterPhaseOne', 'laterPhaseTwo', 'laterPhaseThr', 'laterPhaseFour'];
  var fn = {
    initData: function (order) {
      var fields = ['orderId', 'purchase DetailId', 'companyOrderId', 'factoryNo', 'articleNo', 'purchaseCount', 'inCount', 'purchasePeople',
        'materialName', 'providerName', 'model', 'color'
      ];
      self.setDataFromObj(order, fields);

      var createTime = order.createTime;
      self.createTime = moment(createTime).valueOf();

      var oweCount = self.purchaseCount - self.inCount;
      self.oweCount = _.round(oweCount, 4);

     var tardiness = -order.tardiness;
     if (tardiness < 0) {
      tardiness = 0;
     }
     self.tardiness = tardiness;

      var laterPhase = null;
      for (var i = 0; i < laterPhaseFields.length; i++) {
        var field = laterPhaseFields[i];
        var time = order[field];
        if (SysUtil.isEmpty(time)) {
          continue;
        }

        time = moment(time).valueOf();
        if (laterPhase === null || laterPhase < time) {
          laterPhase = time;
        }
      }
      self.laterPhase = laterPhase;
    }
  };

  fn.initData(order);
};
